/******************************************************************
 * Created by: Goh Chee Hong                                    
 * Date of Creation:
 * Date of last modification: 31st/Jan/2009
 * Status: Finished.
 *                                                                
 * Description: A form that prompts for a response from a user                           
 * ...
 ******************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using Pbdms.BusinessLogic.FileTransfer;
using Pbdms.NetworkDealer;
using Pbdms.Common.DataObject;
using Pbdms.Common.BaseClass;
namespace Pbdms.Forms.Tools
{
    public partial class FrmPermission : newForms
    {
        string[] args = null;
        NetworkDealer.AuthTcpClient authTcpClient;
        public FrmPermission()
        {
            InitializeComponent();
          
            Pbdms.Common.Global.paintBackGround(this);
        }
        public FrmPermission(object sender, NetworkMessage message, string filename)
        {
            

            InitializeComponent();
           
            //spilt into two parameters
            this.authTcpClient = (NetworkDealer.AuthTcpClient)sender;
            args = message.MessageContent.Split(',');
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
            this.lblInfo.Text = "File Name:"+ fileInfo.Name;

        }



        private void btnAccept_Click(object sender, EventArgs e)
        {

            BusinessLogic.FileTransfer.LibraryTransferSenderGui librarySender = new Pbdms.BusinessLogic.FileTransfer.LibraryTransferSenderGui("unknown", "unknown", args[0], args[1], Program.networkCtrller, authTcpClient);
           
            Program.mainForm.frmFileTransfer.addControl(librarySender);
            this.Close();
        
        }

     

        private void btnCancel_Click(object sender, EventArgs e)
        {
            NetworkMessage message = new NetworkMessage();
            message.TypeOfMessage = NetworkDealer.NetworkDealer.DOWNLOAD_REQUEST_REJECTED;
            try
            {
                authTcpClient.sendMessage(message);
            }
            catch
            {

            }
            
            this.Close();
        }
    }
}